package com.approval.approvalapp.center.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.center.bean.ProvinceCensusBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author superman
 * @date 2019/5/9
 */
public class ProvinceCensusAdapter extends BaseRecycleListAdapter<ProvinceCensusBean.TwoBean> {


    public ProvinceCensusAdapter(List<ProvinceCensusBean.TwoBean> mList, Context context) {
        super(mList, context);
    }

    @Override
    public int getLayoutId() {
        return R.layout.province_census_item;
    }

    @Override
    public RecyclerView.ViewHolder createHolder(View view) {
        return new ViewHolder(view);
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, ProvinceCensusBean.TwoBean bean, int position) {
        if (holder instanceof ViewHolder) {
            ((ViewHolder) holder).setData(bean);
        }
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_name1)
        TextView tvName1;
        @Bind(R.id.tv_name2)
        TextView tvName2;
        @Bind(R.id.tv_name3)
        TextView tvName3;
        @Bind(R.id.tv_name4)
        TextView tvName4;
        @Bind(R.id.tv_name5)
        TextView tvName5;
        @Bind(R.id.root)
        LinearLayout root;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void setData(ProvinceCensusBean.TwoBean bean) {

            tvName1.setText(bean.getANAME() + "");
            tvName2.setText(bean.getDTMJ() + "㎡");
            tvName3.setText(bean.getJZBM() + "个");
            tvName4.setText(bean.getCKRS() + "人");
            tvName5.setText(bean.getZXRS() + "人");

            if (bean.getANAME().contains("市")) {
                root.setBackgroundColor(Color.parseColor("#E8EDF7"));
                tvName1.setTextColor(Color.parseColor("#576380"));
                tvName2.setTextColor(Color.parseColor("#576380"));
                tvName3.setTextColor(Color.parseColor("#576380"));
                tvName4.setTextColor(Color.parseColor("#576380"));
                tvName5.setTextColor(Color.parseColor("#576380"));
            } else {
                root.setBackgroundColor(Color.parseColor("#ffffff"));
                tvName1.setTextColor(Color.parseColor("#333333"));
                tvName2.setTextColor(Color.parseColor("#333333"));
                tvName3.setTextColor(Color.parseColor("#333333"));
                tvName4.setTextColor(Color.parseColor("#333333"));
                tvName5.setTextColor(Color.parseColor("#333333"));
            }


        }
    }
}
